package com.fr.report.web.ui.impl;

import com.fr.base.Inter;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.web.ui.Button;
import com.fr.report.web.ui.Icon;
import com.fr.report.web.ui.IconManager;
import com.fr.report.web.ui.ToolBarMenuButton;
import com.fr.web.Repository;
import java.util.ArrayList;
import java.util.List;

public final class Export extends ToolBarMenuButton
{
  private boolean pdfAvailable = true;
  private boolean excelPAvailable = true;
  private boolean excelOAvailable = true;
  private boolean excelSAvailable = true;
  private boolean wordAvailable = true;

  public Export()
  {
    super(Inter.getLocText("Export"), IconManager.EXPORT.getName());
  }

  public boolean isPdfAvailable()
  {
    return this.pdfAvailable;
  }

  public void setPdfAvailable(boolean paramBoolean)
  {
    this.pdfAvailable = paramBoolean;
  }

  public boolean isWordAvailable()
  {
    return this.wordAvailable;
  }

  public void setWordAvailable(boolean paramBoolean)
  {
    this.wordAvailable = paramBoolean;
  }

  public boolean isExcelPAvailable()
  {
    return this.excelPAvailable;
  }

  public void setExcelPAvailable(boolean paramBoolean)
  {
    this.excelPAvailable = paramBoolean;
  }

  public boolean isExcelOAvailable()
  {
    return this.excelOAvailable;
  }

  public void setExcelOAvailable(boolean paramBoolean)
  {
    this.excelOAvailable = paramBoolean;
  }

  public boolean isExcelSAvailable()
  {
    return this.excelSAvailable;
  }

  public void setExcelSAvailable(boolean paramBoolean)
  {
    this.excelSAvailable = paramBoolean;
  }

  public Button[] createMenuItems()
  {
    ArrayList localArrayList = new ArrayList();
    if (this.pdfAvailable)
      localArrayList.add(new PDF());
    if (this.excelPAvailable)
      localArrayList.add(new Excel());
    if (this.excelOAvailable)
      localArrayList.add(new ExcelO());
    if (this.excelSAvailable)
      localArrayList.add(new ExcelS());
    if (this.wordAvailable)
      localArrayList.add(new Word());
    return ((Button[])localArrayList.toArray(new Button[localArrayList.size()]));
  }

  protected JSONObject createChildConfig(Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createChildConfig(paramRepository);
    localJSONObject.put("pdfAvailable", isPdfAvailable());
    localJSONObject.put("excelPAvailable", isExcelPAvailable());
    localJSONObject.put("excelOAvailable", isExcelOAvailable());
    localJSONObject.put("excelSAvailable", isExcelSAvailable());
    localJSONObject.put("wordAvailable", isWordAvailable());
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("Buttons")))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("pdf")) != null)
        setPdfAvailable(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("word")) != null)
        setWordAvailable(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("excelP")) != null)
        setExcelPAvailable(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("excelO")) != null)
        setExcelOAvailable(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("excelS")) != null)
        setExcelSAvailable(Boolean.valueOf(str).booleanValue());
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("Buttons").attr("pdf", this.pdfAvailable).attr("excelP", this.excelPAvailable).attr("excelO", this.excelOAvailable).attr("excelS", this.excelSAvailable).attr("word", this.wordAvailable).end();
  }

  public boolean equals(Object paramObject)
  {
    if ((paramObject == null) || (!(paramObject instanceof Export)))
      return false;
    Export localExport = (Export)paramObject;
    return ((super.equals(paramObject)) && (isExcelPAvailable() == localExport.isExcelPAvailable()) && (isExcelOAvailable() == localExport.isExcelOAvailable()) && (isExcelSAvailable() == localExport.isExcelSAvailable()) && (isPdfAvailable() == localExport.isPdfAvailable()) && (isWordAvailable() == localExport.isWordAvailable()));
  }
}